package com.itheima.myreflect2.Student.convertedio.propertiesio;

import java.util.Map;
import java.util.Properties;
import java.util.Set;

/**
 * @program: Myset
 * @description:这个功能和Map集合一模一样
 * @author: xuejingjing
 * @create: 2021-06-16 13:55
 **/
public class PropertiesDemo1 {
    public static void main(String[] args) {
        Properties prop = new Properties();
        //增
        prop.put("小龙女","尹志平");
        prop.put("郭襄","杨过");
        prop.put("黄蓉","欧阳克");
        System.out.println(prop);

        //删
        prop.remove("郭襄");

        //改 put ---如果键不存在，那么就添加，如果键存在，那么就覆盖
        prop.put("小龙女","杨过");
        prop.put("小龙人","不晓得");
        System.out.println(prop);

        //查
        Object value = prop.get("黄蓉");
        System.out.println(value);
        
        //遍历
        Set<Object> keys = prop.keySet();
        for (Object key : keys) {
            Object value1 = prop.get(key);
            System.out.println("key"+key+"="+value1);
        }
        //-----------------------------------------------------------//
        //键值对
        Set<Map.Entry<Object, Object>> entries = prop.entrySet();
        for (Map.Entry<Object, Object> entry : entries) {
            Object key = entry.getKey();
            Object value1 = entry.getValue();
            System.out.println("key ="+key+",value="+value);
        }
    }
}
